import { createBrowserRouter, Navigate } from 'react-router-dom'
import { Layout } from '@/layout'
import { Doc} from '@/pages/Doc'
// 这里是为了解决 react-router-dom 的类型问题

type PickRouter<T> = T extends (...args: unknown[]) => infer R ? R : never

type A = typeof createBrowserRouter

export const router:PickRouter<A> = createBrowserRouter([
  {
    path: '/',
    element: <Layout/>,
    children: [
      {
        path: 'doc',
        element: <div>DocList</div>,
      },
      {
        path: 'doc/:id',
        element:<Doc />,
      },
      {
            path: 'doc/graph',
            element: <div>DocGraph</div>,
        },
        {
            path: '/',
            element: <Navigate to="/doc" replace />,
        },
    ],
  },
  {
    path: '/home',
    element: <div>home</div>,
    
  },
])